/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 * 定义left、right指针，right从左往右移动，遇上非0元素，交换left和right对应的元素，交换之后left++
 */
 var moveZeroes = function (nums) {
    let l = 0
    let r = 0
    while (r < nums.length) {
        if (nums[r] !== 0) {
            swap(nums, l, r)
            l++
        }
        r++
    }
};
const swap = (nums, l, r) => {
    const temp = nums[l]
    nums[l] = nums[r]
    nums[r] = temp
}